import java.util.concurrent.*;

public class demo50 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService=Executors.newFixedThreadPool(1);
        FutureTask<Integer> futureTask= (FutureTask<Integer>) executorService.submit(new Callable<Integer>(){
            @Override
            public Integer call() throws Exception {
                int sum=0;
                for(int i=1;i<=100;i++){
                    sum=sum+i;
                }
                return sum;
            }
        });
        executorService.shutdown();
        System.out.println("sum="+futureTask.get());

    }
}
